﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>待办</title>
    <link href="/WF/Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="/WF/Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="../../DataUser/JSLibData/CommonShowConfig.js"></script>
    <link href="/WF/Portal/layui/css/layui.css" rel="stylesheet" />
    <script language="JavaScript" src="/WF/Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="/WF/Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="/WF/Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="/WF/Scripts/QueryString.js" type="text/javascript"></script>
    <script src="/WF/Scripts/config.js" type="text/javascript"></script>
    <script src="/WF/Comm/Gener.js" type="text/javascript"></script>
    <script src="/WF/Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>

    <!--路径问题这里直接引入zh-cn.js-->
    <script src="/WF/Data/lang/js/zh-cn.js" type="text/javascript"></script>
    <script src="/WF/Data/lang/lang.js" type="text/javascript"></script>
    <script src="bar.js"></script>
    <script type="text/javascript">
        var webUser = null;

        //页面启动函数.
        $(function () {
            //Hide_IsTodoList:是否隐藏该条信息,CommonShowConfig.js中定义
            if ("undefined" == typeof Hide_IsTodoList) {
                var Hide_IsTodoList = true;
            }

            if (webUser == null)
                webUser = new WebUser();
            if (webUser.No == null)
                return;

            //授权的情况下.
            if (webUser.IsAuthorize == "1") {
                SetHref("AuthorTodolist.htm");
                return;
            }

            InitPage();
        });

        //初始化数据.
        function InitPage() {
            var fk_flow = GetQueryString("FK_Flow");
            document.title = window.lang.daiban;
            //获取当前时间
            var cdt = getNowFormatDate();
            var timeKey = Math.random();

            var handler = new HttpHandler("BP.Cloud.HttpHandler.App_OneFlow");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("Todolist_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            data = cceval('(' + data + ')');

            var tablet = "";
            tablet += "<th style='width:40px;'>#</th>";
            tablet += "<th>" + window.lang.biaoti + "</th>";
            tablet += "<th>" + window.lang.jiedian + "</th>";
            tablet += "<th>" + window.lang.fqr + "</th>";
            tablet += "<th>" + window.lang.fqrq + "</th>";
            tablet += "<th>" + window.lang.sdrq + "</th>";
            tablet += "<th>" + window.lang.qixian + "</th>";
            tablet += "<th>" + window.lang.zhuangtai + "</th>";
            tablet += "<th>" + window.lang.leixing + "<th>";

            $("#tablet").html(tablet);

            var num = 0;
            var is1 = false;
            var realCount = 0;
            var listbox = "";
            //增加处理.
            for (var i = 0; i < data.length; i++) {

                var work = data[i];

                if (fk_flow != data[i].FK_Flow)
                    continue;

                realCount++;

                var newRow = "";
                var title = work.Title;
                var isRead = work.IsRead;
                var flowNo = work.FK_Flow;
                var flowName = work.FlowName;
                var nodeName = work.NodeName;
                var starterName = work.StarterName;
                var pri = work.PRI;
                var nodeID = work.FK_Node;
                var fid = work.FID;
                var workID = work.WorkID;
                var pWorkID = work.PWorkID;
                var paras = work.AtPara;
                if (paras == null)
                    paras = "";

                paras = paras.replace("'", "\\'");
                while (true) {
                    paras = paras.replace('@', '&');

                    if (paras.indexOf('@') < 0) {
                        break;
                    }
                }
                paras = "1" + paras;

                num++;

                if (is1 == true) {
                    listbox += "<tr  id='" + num + "' >";
                    is1 = false;
                }
                else {
                    listbox += "<tr   id='" + num + "' >";
                    is1 = true;
                }

                listbox += "<td>" + num + "</td>"; //序号.

                var url = "";
                if (paras.indexOf("&IsCC=1") >= 0
                    || paras.indexOf("&IsAuto=1") >= 0) {

                    var batchUrl = '/WF/MyView.htm?FK_Flow=' + flowNo + '&FK_Node=' + nodeID + '&WorkID=' + workID + '&FID=' + fid;
                    url = "<a href='#'  onclick='WinOpenFull(\"" + batchUrl + "\")'>" + data[i].Title + "</a>";

                } else {
                    if (isRead == 0)
                        url = "<a href=\"javascript:WinOpenIt('/WF/MyFlow.htm?FK_Flow=" + flowNo + "&PWorkID=" + pWorkID + "&FK_Node=" + nodeID + "&FID=" + fid + "&WorkID=" + workID + "&IsRead=0&T=" + timeKey + "&Paras=" + paras + "');\" ><img class=Icon align='middle'  src='/WF/Img/Mail_UnRead.png' />" + title + "</a>";
                    else
                        url = "<a href=\"javascript:WinOpenIt('/WF/MyFlow.htm?FK_Flow=" + flowNo + "&PWorkID=" + pWorkID + "&FK_Node=" + nodeID + "&FID=" + fid + "&WorkID=" + workID + "&IsRead=0&T=" + timeKey + "&Paras=" + paras + "');\" ><img class=Icon align='middle'  src='/WF/Img/Mail_Read.png' />" + title + "</a>";
                }

                listbox += "<td>" + url + "</td>"; //标题

                listbox += "<td>" + nodeName + "</td>"; //节点名称
                listbox += "<td>" + starterName + "</td>"; //发起人

                listbox += "<td>" + work.RDT + "</td>"; //发起时间
                listbox += "<td>" + work.ADT + "</td>"; //接受时间
                listbox += "<td>" + work.SDT + "</td>"; //应完成时间

                //为天业解决开始节点撤销回来后，就是逾期状态.
                var len = nodeID.toString().length;
                var entStr = nodeID.toString().substr(len - 2);

                //判断期限是否少于三天，加警告颜色
                var date = new Date();
                var edt = work.SDT.replace(/\-/g, "/");
                edt = new Date(Date.parse(edt.replace(/-/g, "/")));
                passTime = GetSpanTime(date, edt);
                //判断流程是否逾期
                if (date.getTime() > edt.getTime() && work.WFState == 2 && entStr != "01" && work.RDT != work.SDT
                    && paras.indexOf("&IsCC=1") == -1) {
                    listbox += "<td><font color=red>" + window.lang.yuqi + "</font></td>";
                }
                else {
                    if (passTime >= 0 && passTime < 2 * 24 * 3600 * 1000) {
                        listbox += "<td><font color='#ffac38'>" + window.lang.jinggao + "</font></td>";
                    } else {
                        listbox += "<td><font color=green>" + window.lang.zhengchang + "</font></td>";
                    }
                }

                listbox += "<td>" + GetState(work.WFState) + "</td>";
                listbox += "</tr>";
            }


            $('#Table1').html(listbox);
            $("#Table2").html(window.lang.heji + ": " + realCount + " " + (realCount > 1 ? window.lang.records : window.lang.record));


            //if (webUser.IsAuthorize == "0" && Hide_IsTodoList == true)
            // $("#Table2").append(", <a href='AuthorList.htm' >查看授权待办</a>");
            //   $("#Table2").append(", <a href='AuthorList.htm' >查看授权待办</a>");


            var div = window.parent.document.getElementById("Todolist_EmpWorks");
            if (div != null) {
                div.innerHTML = realCount;
            }
        }
        function GetState(wfState) {


            switch (parseInt(wfState)) {
                case 1:
                    return window.lang.caogao;
                case 2:
                    return window.lang.daiban;
                    break;
                case 3: //已完成.
                    return window.lang.ywc;
                    break;
                case 4:
                    return window.lang.guaqi;
                case 5:
                    return "<font color=red>" + window.lang.tuihui + "</font>";
                case 6:
                    return window.lang.zhuanfa;
                case 7:
                    return window.lang.shanchu;
                case 8:
                    return window.lang.jiaqian;
                case 11:
                    return window.lang.jqhf;
                default:
                    return window.lang.other;
            }
        }
        //获取当前时间
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var hour = date.getHours();
            if (hour >= 1 && hour <= 9) {
                hour = "0" + hour;
            }
            var minute = date.getMinutes();
            if (minute >= 1 && minute <= 9) {
                minute = "0" + minute;
            }
            //当前时间=年份-月份-日 小时：分钟
            var cdt = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + hour + seperator2 + minute;

            return cdt;
        }
        function GetSpanTime(date1, date2) {
            var date3 = date2.getTime() - date1.getTime();  //时间差秒
            return date3;
        }
        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {
                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-minus-square';
            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-plus-square';
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById(groupName + i);

                if (row == null || row == undefined || row.style == null)
                    continue;

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }

        //打开默认窗口
        function WinOpenFull(url) {
            layer.open({
                skin: 'layer-class',
                type: 2,
                title: '待办',
                area: ['96%', '90%'],
                content: url
            });
        }

        function WinOpenIt(url) {
            var self = window.open(url);
            var loop = setInterval(function () {
                if (self.closed) {
                    clearInterval(loop);
                    InitPage();
                    InitHomeCount();
                }
            }, 1);
        }
    </script>
</head>

<body class="gray-bg">
    <div id="toolbar" class="layui-header">
    </div>

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
            <table class="table  table-striped">
                <thead>
                    <tr id="tablet">
                    </tr>
                </thead>
                <tbody id="Table1">
                </tbody>
            </table>
            <div class="row">
                <div class="col-sm-12">
                    <span id="Table2"></span>
                </div>
            </div>
        </div>
    </div>



</body>



</html>
